package com.breadenglish.cms.api.app.gateway.manager;


import com.breadenglish.cms.api.app.gateway.model.CourseStatistics;
import com.breadenglish.cms.api.app.gateway.util.Util;
import org.jsondoc.core.annotation.*;
import org.jsondoc.core.pojo.ApiStage;
import org.jsondoc.core.pojo.ApiVisibility;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;

@Api(name = "个人中心", description = "用户课程统计数据及基本信息", group = "客户端接口", visibility = ApiVisibility.PUBLIC, stage = ApiStage.RC)
@ApiVersion(since = "1.0", until = "2.12")
@ApiAuthNone
@RestController
@RequestMapping(value = "/coursestatistics")
public class CourseStatisticsController {

    LinkedHashMap<Integer, CourseStatistics> data = new LinkedHashMap();

    public CourseStatisticsController() {
        int id = 100;
        data.put(id, CourseStatistics.build("" + id--, "http://img0.bdstatic.com/img/image/shouye/xinshouye/mingxing16.jpg", "学员李四", "小四", 3, 56, 0.5f, Util.parseToDate("2016-05-06")));
        data.put(id, CourseStatistics.build("" + id--, "http://img0.bdstatic.com/img/image/shouye/xinshouye/mingxing16.jpg", "学员张三", "小三", 0, 0, 0f, Util.parseToDate("2016-05-08")));

    }

    @ApiMethod
    @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
    public
    @ApiResponseObject
    CourseStatistics get(@ApiPathParam(description = "根据userId获取学员课程数据") @PathVariable(value = "userId") int userId) {
        return data.get(userId);
    }

}